<!--大小额贷记业务审核管理画面-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
      :defaultEventKey="defaultEventKey"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="id"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :defaultEventKey="defaultEventKey"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="queryDetailDialog" :dictMap="dictMap"></query-detail-dialog>
    <detail111 ref="detail111" :dictMap="dictMap" @editComplete="editComplete"></detail111>
    <detail112 ref="detail112" :dictMap="dictMap" @editComplete="editComplete"></detail112>
    <detail115 ref="detail115" :dictMap="dictMap" @editComplete="editComplete"></detail115>
    <detail116 ref="detail116" :dictMap="dictMap" @editComplete="editComplete"></detail116>
    <detail118 ref="detail118" :dictMap="dictMap" @editComplete="editComplete"></detail118>
  </div>
</template>
<script>
import { apiUrlConfig } from "@/api/cnaps/baseBiz/send/auth/index";
import QueryDetailDialog from "./components/Details";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
import Detail111 from "@/views/cnaps/baseBiz/send/auth/components/detail111";
import Detail112 from "@/views/cnaps/baseBiz/send/auth/components/detail112";
import Detail115 from "@/views/cnaps/baseBiz/send/auth/components/detail115";
import Detail116 from "@/views/cnaps/baseBiz/send/auth/components/detail116";
import Detail118 from "@/views/cnaps/baseBiz/send/auth/components/detail118";
export default {
  name: "CreditCheck",
  mixins: [listPageMixin],
  components: {
    Detail118,
    Detail116,
    Detail115,
    Detail112,
    Detail111,
    AmountRangeSearch,
    QueryDetailDialog,
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      defaultEventKey: "defaultEventKey",

    //数据字典
      searchFormDictList: ["TXN_STATUS","PRIORITY3CODE","TXN_SOURCE","CUST_FLAG1","CBFLAG","CLLTN_NOTES_TYPE","DFT_CTGY",
        "BANK_NOTE_TYPE","STATUS_115","DRCTCODE","BIZ_TYPE_115","BIZ_CTGY","FEE_CODE"],
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        amount1: "",
        amount2: "",
        source: "",
      },
      formOptions: [],
      tableBindColumns: [
        { label: `交易流水号`, prop: "id", width: "160" },
        {
          label: `报文类型`,
          prop: "pkgtype",
          dictCode: "PKG_TYPE_HVPSBEPS",
          sortable: false,
          width: "160",
        },
        { label: `CPG日期`, prop: "cpgdate", width: "100", sortable: false },
        { label: `工作日期`, prop: "workdate", width: "100" },
        {
          label: `业务类型`,
          prop: "bizTypeCode",
          formatter: (row) => {
            if (!row.bizTypeCode) {
              return "-";
            }
            return `${row.bizTypeCode + "-" + row.bizTypeCodeDesc}`;
          },
          sortable: false,
          width: 200,
        },
        {
          label: `业务种类`,
          prop: "bizCtgyCode",
          formatter: (row) => {
            if (!row.bizCtgyCode) {
              return "-";
            }
            return `${row.bizCtgyCode + "-" + row.bizCtgyCodeDesc}`;
          },
          sortable: false,
          width: 200,
        },

        {
          label: `交易状态`,
          prop: "bizStatus",
          width: "100",
          dictCode: "TXN_STATUS",
          sortable: false,
        },
        {
          label: `录入操作员`,
          prop: "mdTlrno",
          width: "100",
          sortable: false,
        },
        {
          label: `复核操作员`,
          prop: "ckTlrno",
          width: "100",
          sortable: false,
        },
        {
          label: `审核操作员`,
          prop: "audTlrno",
          width: "100",
          sortable: false,
        },
        {
          label: `审核时间`,
          prop: "audTime",
          width: "160",
          sortable: false,
        },
      ],
    };
  },
  mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          label: "CPG日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.$refs.dataTable.doQuery(true);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*查看明细*/
    toViewDetail(row) {
      if(row.pkgtype==='hvps.111.001.01'){
        this.$refs.detail111.show(row.id, row.pkgtype);
      }else if(row.pkgtype==='hvps.112.001.01'){
        this.$refs.detail112.show(row.id, row.pkgtype);
      }else if(row.pkgtype==='hvps.115.001.01'){
        this.$refs.detail115.show(row.id, row.pkgtype);
      }else if(row.pkgtype==='hvps.116.001.01'){
        this.$refs.detail116.show(row.id, row.pkgtype);
      }else if(row.pkgtype==='hvps.118.001.01'){
        this.$refs.detail118.show(row.id, row.pkgtype);
      }else{
        this.msgError("报文类型错误")
      }
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
